package com.mofang.adapters;

import java.util.List;
import java.util.Map;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.mofang.R;

public class CommissionSubsidiaryAdapter extends BaseAdapter{
	Context c;
	List<Map<String, Object>> list;
	private LayoutInflater inflater;
	public CommissionSubsidiaryAdapter(Context context,
			List<Map<String, Object>> list) {
		// TODO Auto-generated constructor stub
		inflater = LayoutInflater.from(context);
		this.c=context;
		this.list=list;
		
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {
		// TODO Auto-generated method stub
		Holder myHolder;
		if (convertView == null) {
			myHolder = new Holder();
			convertView = inflater.inflate(R.layout.commission_subsidiary_list_item, null);
			
			myHolder.name = (TextView) convertView.findViewById(R.id.commission_name);
			myHolder.phone = (TextView) convertView.findViewById(R.id.phone_number);
			myHolder.commission = (TextView) convertView.findViewById(R.id.commission);
			myHolder.date = (TextView) convertView.findViewById(R.id.date);
			convertView.setTag(myHolder);
		} else {
			myHolder = (Holder) convertView.getTag();
		}
		myHolder.name.setText(list.get(position).get("name").toString());
		myHolder.phone.setText(list.get(position).get("phone").toString());
		myHolder.commission.setText(list.get(position).get("commission").toString());
		myHolder.date.setText(list.get(position).get("date").toString());
		return convertView;
	}
	class Holder {
		TextView name;
		TextView phone;	
		TextView commission;
		TextView date;
	}
}
